$(function () {
    $('#oidPassword').blur(function () {
        var name = $('#account').val();
        var password =  $('#oidPassword').val();
        var user = {}
        user["name"] = name;
        user["password"] = password;
        if(password==""){
            alert("请输入原密码！")
            return;
        }
        $.ajax({
            type: "POST",
            url: "../user/password",
            dataType:'json',
            data:user,
            success:function(data){
                if (data==1){
                    alert("信息为空")
                    return;
                }else if (data==2){
                    alert("原密码错误")
                    return;
                }
            },
            dataType:"text"
        });
    });

    $('#newPasswordt').blur(function () {
        var newPassword = $('#newPassword').val();
        var newPasswordt =  $('#newPasswordt').val();
        if (newPasswordt!=newPassword){
            alert("两次输入的密码不一致！")
            return;
        }
    });
})
$(function () {
    $('#yesupdate').click(function () {
        var newPassword =  $('#newPasswordt').val();
        var newPasswordt =  $('#newPasswordt').val();
        if(newPassword==""||newPasswordt==""){
            alert("请输入新密码！")
            return;
        }
        var name = $('#account').val();
        var password =  $('#oidPassword').val();
        var user = {}
        user["name"] = name;
        user["password"] = password;
        if(password==""){
            alert("请输入原密码！")
            return;
        }
        $.ajax({
            type: "POST",
            url: "../user/password",
            dataType:'json',
            data:user,
            success:function(data){
                if (data==1){
                    alert("信息为空")
                    return;
                }if (data==2){
                    alert("原密码错误")
                    return;
                }if (data==0){
                    alert("修改成功！")
                    location.href="../user/updatePassword?newPassword="+newPassword;
                }
            },
            dataType:"text"
        });
    });
})